$files = Get-ChildItem -Path .\ -Recurse -Filter *.cs | Where-Object { (Get-Content $_.FullName) -match '\[Entity\(' }

Write-Host "Found $($files.Count) files to fix"

foreach ($file in $files) {
    $content = Get-Content $file.FullName -Raw
    
    # Check if file already contains the namespace
    if ($content -notmatch 'using VOL.Entity.AttributeManager;') {
        # Add the new namespace reference after the last using statement
        $newContent = $content -replace '(using [^;]+;\s+)(?!using)', '$1using VOL.Entity.AttributeManager;' + [Environment]::NewLine + [Environment]::NewLine

        # If no match was found, try to add before the namespace declaration
        if ($newContent -eq $content) {
            $newContent = $content -replace '(namespace [^{]+\s*{)', 'using VOL.Entity.AttributeManager;' + [Environment]::NewLine + [Environment]::NewLine + '$1'
        }
        
        # Save the modified content
        Set-Content -Path $file.FullName -Value $newContent
        Write-Host "Fixed $($file.FullName)"
    } else {
        Write-Host "Skipped $($file.FullName) - already contains required namespace"
    }
} 